﻿<%@ Page  MasterPageFile="~/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="Address.aspx.cs" Inherits="RabbitShop.UI.Address" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <form id="form1" action="../Action/UserAddress.aspx" method="POST">
        <hgroup class="title">
            <h2>User Register</h2>
        </hgroup>
        
        <script type="text/javascript">

            form1.onsubmit = function (e) {
                // stop the regular form submission
                e.preventDefault();

                // collect the form data while iterating over the inputs
                var data = {};
                for (var i = 0, ii = form1.length; i < ii; ++i) {
                    var input = form1[i];
                    if (input.name) {
                        data[input.name] = input.value;
                    }
                }

                // construct an HTTP request
                var xhr = new XMLHttpRequest();
                xhr.open(form1.method, form1.action, true);
                xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

                // send the collected data as JSON
                xhr.send(JSON.stringify(data));

                xhr.onloadend = function () {
                    // done
                    if (xhr.responseText == "true") {
                        window.location = "/UI/Address.aspx";
                    } else {
                        alert(xhr.responseText);
                    }
                };
            };
        </script>
        <script type="text/javascript" src="/Scripts/city.js"></script>

        <table>
            <tr>
                <td>
                    收件地址：
                    <select id="cmbProvince"></select>
                    <select id="cmbCity"></select>
                    <select id="cmbArea"></select>
                    <br/>
                    <%--<input type="text" id="inputProvince" name="Province" style="width: 50px;" />省
                    <input type="text" id="inputCity" name="City" style="width: 50px;"  />市--%>
                    <input type="text" id="inputDetail" name="Detail" style="width: 540px;"  />
                </td>
                
            </tr>
            <tr>
                <td>
                    收件人：
                    <input type="text" id="inputContactName" name="ContactName" style="width: 120px;" />
                    电话：
                    <input type="text" id="inputContactPhone" name="ContactPhone" style="width: 120px;"  />
                    邮编：
                    <input type="text" id="inputPostalCode" name="PostalCode" style="width: 120px;" />
                </td>
                
            </tr>

        </table>

        <input type="submit" value="添加" />
        
        <script type="text/javascript">
            addressInit('cmbProvince', 'cmbCity', 'cmbArea', '四川', '成都市', '郫县');
        </script>

    </form>
    
</asp:Content>